package com.xuecheng.orders.service;

import com.alipay.api.AlipayApiException;
import com.xuecheng.messagesdk.model.po.MqMessage;
import com.xuecheng.orders.model.dto.AddOrderDto;
import com.xuecheng.orders.model.dto.PayRecordDto;
import com.xuecheng.orders.model.dto.PayStatusDto;
import com.xuecheng.orders.model.po.XcPayRecord;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @description: 订单相关的service接口
 * @author: ajie
 * @date: 2024/2/3 20:35:22
 * @version: 1.0
 */
public interface OrderService {

    /**
     * @description 创建商品订单
     * @param addOrderDto 订单信息
     * @return PayRecordDto 支付交易记录(包括二维码)
     * @author Mr.M
     * @date 2022/10/4 11:02
     */
    public PayRecordDto createOrder(String userId, AddOrderDto addOrderDto);

    /**
     * @description 查询支付交易记录
     * @param payNo  交易记录号
     * @return com.xuecheng.orders.model.po.XcPayRecord
     * @author Mr.M
     * @date 2022/10/20 23:38
     */
    public XcPayRecord getPayRecordByPayno(String payNo);


    /**
     * @description: 扫码下单接口 
     * @params: [payNo, httpResponse]       
     * @return: 
     * @author: ajie
     * @date: 2024/2/4 20:21
     */
    void requestpay(String payNo, HttpServletResponse httpResponse) throws AlipayApiException, IOException;

    /**
     * 请求支付宝查询支付结果
     * @param payNo 支付记录id
     * @return 支付记录信息
     */
    public PayRecordDto queryPayResult(String payNo);

    /**
     * @description 保存支付宝支付结果
     * @param payStatusDto  支付结果信息
     * @return void
     * @author Mr.M
     * @date 2022/10/4 16:52
     */
    public void saveAliPayStatus(PayStatusDto payStatusDto);

    /**
     * @description: 接收通知
     * @params: [request, response]
     * @return:
     * @author: ajie
     * @date: 2024/2/5 20:36
     */
    void paynotify(HttpServletRequest request, HttpServletResponse response) throws AlipayApiException, IOException;

    /**
     * 发送通知结果
     * @param message
     */
    public void notifyPayResult(MqMessage message);

}
